<script setup>
  import { ref } from 'vue'
  import {login} from '@/api/login.js'
  import { useRouter } from 'vue-router'
  
  let Router = useRouter()
  let loginForm = ref({username:'', password:''})
  const startLogin =async()=>{
    const result= await login(loginForm.value)
    localStorage.setItem('loginUser',JSON.stringify(result.data))
    Router.push('/user')
  }
  
</script>

<template>
  <div id="container">
    <div class="login-form">
      <el-form label-width="80px">
        <el-form-item label="用户名" prop="username">
          <el-input v-model="loginForm.username" placeholder="请输入用户名"></el-input>
        </el-form-item>

        <el-form-item label="密码" prop="password">
          <el-input type="password" v-model="loginForm.password" placeholder="请输入密码"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button class="button" type="primary" @click="startLogin">登 录</el-button>
          <el-button class="button" type="info" @click="">重 置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<style scoped>

</style>